package top.kaoshanji.p3ch11a;

/**
 * 代码清单-p3ch11a-341页a：使用 volatile 变量作为循环结束的判断条件
 * author kaoshanji
 * ^_^
 * create time 2025/2/3 16:24
 */
public class Worker {

    private volatile boolean done;

    public void setDone(boolean done) {
        this.done = done;
    }

    public void work() {
        while (!done) {
            // 执行任务
        }
    }

}
